export function getYMD(time) {
  const d = new Date(time)
  const year = d.getFullYear()
  let month = d.getMonth() + 1
  let day = d.getDate()
  if (month < 10) month = '0' + month
  if (day < 10) day = '0' + day
  return year + '-' + month + '-' + day
}
export function getAllyear(time) {
  const d = new Date(time)
  const year = d.getFullYear()
  let month = d.getMonth() + 1
  let day = d.getDate()
  if (month < 10) month = '0' + month
  if (day < 10) day = '0' + day
  return year 
}
// export function getYMD(time) {
//   let d = new Date(time)
//   return d.getTime()/1000
// }

export function formatDate(time) {
  const d = time ? new Date(time) : new Date()
  const year = d.getFullYear()
  let month = d.getMonth() + 1
  let day = d.getDate()
  let hours = d.getHours()
  let min = d.getMinutes()
  let seconds = d.getSeconds()

  if (month < 10) month = '0' + month
  if (day < 10) day = '0' + day
  if (hours < 0) hours = '0' + hours
  if (min < 10) min = '0' + min
  if (seconds < 10) seconds = '0' + seconds

  return (year + '-' + month + '-' + day)

}

export function formatYMDDate(date) {
  const yyyy = date.getFullYear()
  const MM = String(date.getMonth() + 1).padStart(2, '0')
  const dd = String(date.getDate()).padStart(2, '0')
  console.log('yyyy : ' + yyyy)
  console.log('MM : ' + MM)
  console.log('dd : ' + dd)
  return `${yyyy}${MM}${dd}`
}

export function formatYMDDate1(date) {
  const yyyy = date.getFullYear()
  const MM = String(date.getMonth() + 1).padStart(2, '0')
  const dd = String(date.getDate()).padStart(2, '0')
  console.log('yyyy : ' + yyyy)
  console.log('MM : ' + MM)
  console.log('dd : ' + dd)
  return yyyy + '-' + MM + '-' + dd
}
